<?php
	include("config.php");	
	session_start();
	if($_SERVER["REQUEST_METHOD"]=="POST")
	{
		$username = addslashes($_POST['name']);
		$password = md5(addslashes($_POST['pass']));
		
		$sql ="SELECT * FROM Customer WHERE email='$username' AND password='$password'";
		$result = mysql_query($sql);
		$count = mysql_num_rows($result);		
		if($count==1)
		{
			session_register("myusername");
			$_SESSION['login_user'] = $username;
			$_SESSION['logged_in'] = true;
			header("location:shop.php");
		}
		else
			$error="Your email or password is invalid";
	}
	require_once("../inc/models/products_model.php");
        if(isset($_GET['catID']))
                $results = GetProductByCat($_GET['catID']);
        else
                $results = GetProducts();
        require_once("../inc/models/product_category_model.php");
        $categories = GetProductKeywords();
?>
<!DOCTYPE html>
<html lang="en">
<?php include('../inc/head.php'); ?>
<body>	 
	 <?php
	 	if($_SESSION['logged_in']===true) 
			include('../inc/nav2.php');
		else	
	 		include('../inc/nav.php');	 
	 ?>     
	 <div class="container-fluid">
      <div class="row-fluid">
        <div class="span3">
          <div class="well sidebar-nav">
            <ul class="nav nav-list">
              <li class="nav-header">Categories</li>
              <? while($cat = $categories->fetch_assoc()) : ?>
              <li><a href="shop.php?catID=<?=$cat['id']?>"><?=$cat['Value']?></a></li>
              <?php endwhile; ?>
            </ul>
          </div><!--/.well -->
        </div><!--/span-->
        <div class="span9">               
          <div class="row-fluid">
                        <? while($rs = $results->fetch_assoc()): ?>
                <div style="width: 150px; float: left; margin: 5px;">
                        <div style="height: 150px;">
                        <img src="inc/images/thumbnails/<?=$rs['thumbnail']?>" />
                    </div>
                    <h6><?=$rs['name']?> </h6>
                    <h5>Price: <?=$rs['price']?></h5>
                    <a class="add-to-cart-link" href="cart.php?id=<?=$rs['id']?>"><img src="../inc/images/btn_add_to_cart.png"</a>
                </div>
            <? endwhile; ?>
              </div><!--/row-->
   			</div>
   		</div>
   	</div>
    <!-- Le javascript
    ================================================== -->
    <!-- Placed at the end of the document so the pages load faster -->
    <script src="../inc/bootstrap/js/jquery.js"></script>
    <script src="../inc/bootstrap/js/bootstrap-min.js"></script>
</body>
</html>